home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / battutor.arc / _ELEM.REM next >
Text File  |  1986-05-05  |  9KB  |  155 lines

  1.                             Text File      _elem.rem
  2.  
  3.  
  4.  
  5. Here's a short list of journal articles and other references to get you
  6. started.
  7.  
  8. A two-part tutorial on Batch Files appears in the "System Notebook" column of
  9. SOFTALK magazine, October and November, 1982.  In general, back issues of
  10. SOFTALK are an excellent source of information for the neophyte PC user.
  11.  
  12. A very interesting application of the DOS 2.0 Batch File capabilities can be
  13. found in Tom Sheldon's "One from Column A, One from Column B", PC WORLD
  14. magazine, Vol. 1, Number 5.
  15.  
  16. Of course, the definitive source of information remains the DOS 2.0 Manual
  17. itself, pp. 6-28 to 6-49.
  18.  
  19.  
  20.  
  21.  
  22.  
  23. For those of you who are anxious to write your first Batch Files and who don't
  24. have access to the above references, here is a "micro-tutorial".
  25.  
  26. We'll assume that you are familiar with the idea of the DOS prompt "A>" being a
  27. request from the DOS command processor for the name of an executable file to
  28. load and run, such as DOS's FORMAT, DISKCOPY, BASICA, or any other executable
  29. file such as a word processor, spread sheet program, and the like;  or for the
  30. name of an internal command, such as TIME, DATE, DIR, COPY, PATH, etc, that the
  31. command processor itself executes.  Every time you see the A> prompt (or B>,
  32. etc), DOS is quietly listening to the keyboard for the next command to be
  33. entered.  When you enter a command line in answer to this prompt, DOS then
  34. either executes the command directly or else loads and runs a program.  In
  35. either case, when the "process" that the command evokes has run to completion,
  36. DOS regains control of the PC and displays its prompt and quietly waits for
  37. another command from you.
  38.  
  39. Some users hardly ever talk directly to DOS, spending most of their time in the
  40. execution of applications programs.  Other users may have extensive dialogues
  41. with DOS, using commands whose syntax is often difficult to remember and
  42. in which a misspelled name or misplaced character can spell disaster.
  43.  
  44. When your use of the PC involves command dialogues with DOS (copying disks,
  45. copying files, looking at directories, calling a series of language processors
  46. for program development, etc), then after a while you'll notice that you are
  47. using some sequences of commands over and over again, perhaps with just a
  48. change of a filename or other parameters.  Wouldn't it be nice to type that
  49. sequence of DOS command lines just one more time, put a label on it, and then
  50. magically execute the entire sequence by simply typing its label, perhaps even
  51. dubbing a filename into some of the commands so that you could run the same
  52. sequence of commands with different files.  That is exactly what a Batch File
  53. does for you, plus a lot more.
  54.  
  55. Here are the mechanics of creating this labeled sequence of commands that we
  56. call a Batch File.  First, ask DOS to run your favorite text editor that
  57. produces "DOS-compatible ascii text files" without a lot of fancy control
  58. characters imbedded in the text.  Examples of text editors that create such
  59. files are DOS's own EDLIN (a limited but adequate line editor), Volkswriter
  60. with "programmer's margins", WORDSTAR in "non-document" mode, VEDIT, The
  61. Personal Editor, and a host of public domain editors.  An example of a "text
  62. editor" (word processors are just glorified text editors) that DOES NOT
  63. directly create clean text files is Easy Writer II.
  64.  
  65. When you have mastered a text editor well enough to correctly enter and edit a
  66. few lines of text, then type the sequence of DOS commands that you wish to
  67. "automate", line by line, just as you would if you were entering them in
  68. response to the DOS ">" prompt.  Finally, tell the text editor to store these
  69. lines in a file with a filename that has a ".BAT" extension, such as FOO.BAT.
  70.  
  71. Now, the fun starts.  Remember that whenever you see the DOS ">"  prompt, you
  72. can give DOS the name of any executable file and DOS will run it for you.  The
  73. filenames that DOS recognizes as executable are those ending with .COM, .EXE,
  74. and, you guessed it, .BAT . So answer the DOS prompt with FOO (you don't type
  75. the .BAT, just as you don't type the .COM when you ask for the FORMAT
  76. command).
  77.  
  78. As DOS begins to execute your Batch File, it displays the familiar ">" prompt
  79. on the screen.  But now, instead of waiting patiently by the keyboard for your
  80. response, DOS reads the first line of text from your FOO.BAT file, displays it
  81. on the screen, and immediately executes it, just as if you had typed it
  82. (lightning quick) as a response to the ">".  DOS has, in effect, replaced the
  83. keyboard with the FOO.BAT file as the place it goes to get a response to its
  84. ">" prompt. Any programs that are run by your command lines in the FOO.BAT file
  85. are free to use the keyboard, but DOS itself gets its commands from the FOO.BAT
  86. file until the list of command lines is exhausted.
  87.  
  88. This appears to be a pretty good way to enter some long command line sequences,
  89. or command lines that tax the most accurate typist.  But there is much more to
  90. Batch Files than saving keystrokes.  When you create the Batch File FOO.BAT,
  91. you can insert "place-holders" (or formal parameters) in the command lines for
  92. information that will be known only at the time that the Batch File is run.
  93. For example, if you want a command line in a Batch File to always copy a file
  94. with the basic extension .BAS from drive A: to drive B: and change its
  95. extension to .SAV at the same time, you could use the following Batch File
  96. command line:
  97.  
  98.                 copy  a:%1.bas  b:%1.sav
  99.  
  100. The "%1" is a place-holder for a string of characters that will be substituted
  101. into the command line later when the Batch File is executed. If this line were
  102. created and saved in the file called SAVIT.BAT, then in order to perform the
  103. above operation on the Basic file MYFILE.BAS, you would type the command:
  104.  
  105.                 A> savit  myfile
  106.  
  107. DOS will now run the SAVIT.BAT file, and, whenever it arrives at a place-holder
  108. "%1", it will substitute the first parameter found on the SAVIT command line,
  109. namely MYFILE in this example. The command line that will therefore be executed
  110. from the Batch File is the following:
  111.  
  112.                 copy a:myfile.bas  b:myfile.sav
  113.  
  114. SAVIT.BAT now becomes a general tool for doing this particular file operation.
  115. This is a simple operation, but you can see that there is a powerful capability
  116. to save you time, keystrokes, and damage from mistakes, by putting repetitive
  117. sequences of DOS commands into Batch Files.
  118.  
  119. With the release of DOS 2.0, Batch Files have been given looping, testing, and
  120. branching (GOTO) subcommands to program the flow of control through the command
  121. lines.  Now a Batch File is no longer limited to a "linear" list of command
  122. lines that is executed one time only.  You can create arbitrarily complex
  123. "command line programs" that make decisions during the Batch File execution
  124. based upon intermediate results.  In fact, the purpose of the utilities on this
  125. disk is to expand the scope of the information that an executing Batch File can
  126. obtain in order to make branching decisions.  But more on that later.
  127.  
  128. One special Batch File worth noting is called the AUTOEXEC.BAT file.  This is a
  129. "reserved filename", meaning that this file, if it exists, gets special
  130. treatment from DOS.  Whenever DOS is "booted" (that is, whenever you turn on
  131. the PC or start over again by typing CTRL-ALT-DEL), DOS will go look on the A:
  132. drive for a file with this name and, if found, will execute all of the commands
  133. in this special Batch File before turning control over to you with the ">"
  134. prompt.  The AUTOEXEC.BAT file is a convenient means to do initializing tasks
  135. automatically, such as reading the time and date from a hardware
  136. clock-calendar, or creating a RAM disk.  Some applications programs, such as
  137. Volkswriter, supply an AUTOEXEC.BAT file that immediately calls the application
  138. program, obviating your need to talk to DOS at all.  You turn on the computer,
  139. and it jumps into the word processor.
  140.  
  141. The best way to learn how to create and execute Batch File is ... to create
  142. some and execute them.  We encourage you to stop the tutorial at this point and
  143. try your hand at it.  Write and execute a few Batch Files until you get the
  144. hang of it, then restart this tutorial.  If you're unfamiliar with any text
  145. editors or word processors that operate in "programming" mode, then EDLIN would
  146. be a good one to master, since it comes with DOS and is adequate for creating
  147. small files.
  148.  
  149. If, however, you have a pretty good grasp of the mechanics of creating and
  150. executing a Batch File (or you're just plain impatient to see what else is on
  151. this disk), that's ok, too.  But you might skim over the DOS 2.0 Manual's
  152. pages 6-28 to 6-49, to get yourself oriented for the ensuing discussion.
  153.  
  154. So ...
  155. u&╟ïFⁿÄ^■ïσ]╦MW_ZTRUNC    Uï∞╕εÄ╪+└PìFPèF*ΣPÜ σâ─Ä^■ïσ]╦MW_FILE_TIMESUï∞╕εÄ╪╕ε